package com.sanyang.logistics.WarehouseManager.handler;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sanyang.logistics.WarehouseManager.dao.PickoutDao;
import com.sanyang.logistics.WarehouseManager.service.PickoutService;
import com.sanyang.logistics.pojo.PickOut;
import com.sanyang.logistics.pojo.PickoutProdBridge;
import com.sanyang.logistics.pojo.PrepareOutWarehouse;
import com.sanyang.logistics.pojo.Warehouse;

@Controller
@RequestMapping("/ccgl")
public class PickoutHander {

	@Autowired
	private PickoutService zservice;
	
	@RequestMapping("/ou")
	@ResponseBody
	public Object all(PickOut pickOut,Integer wh_id){
		pickOut.setWh_id(wh_id);
		
		System.out.println(pickOut.getWh_id());
		List<PickOut> al = zservice.queryAll(pickOut);
		for (PickOut pickOut2 : al) {
			String done_flag = pickOut2.getDone_flag();
			if (done_flag.equals("Y")) {
				pickOut2.setDone_flag("拣货完成");
			}else {
				pickOut2.setDone_flag("正在拣货");
			}
		}
		
		
		return al;
	}
	
	
	@RequestMapping("/so")
	@ResponseBody
	public Object ll(){
	   List<Warehouse> querySome = zservice.querySome();
	   
	   return querySome;
	}
	
	@RequestMapping("/mxb")
	@ResponseBody
	public Object getPick(Integer pickout_id){
		System.out.println(pickout_id);
		List<PickoutProdBridge> all = zservice.getAll(pickout_id);
		System.out.println(all+"++++++++++++++++++");
		return all;
	}
	
	
	 @RequestMapping("/upSome")
	 @ResponseBody
	  public void upd(PickoutProdBridge pickoutProdBridge,Integer pickout_prod_id,Integer out_amt1) {
//		 System.out.println(pickoutProdBridge.getPickout_prod_id()+"--");
//		 System.out.println(pickoutProdBridge.getOut_amt1()+"--");
//		 pickoutProdBridge.setPickout_prod_id(pickout_prod_id);
//		 pickoutProdBridge.setOut_amt1(out_amt1);
		 
			zservice.upd(pickoutProdBridge);
			zservice.del();
			zservice.tj(pickoutProdBridge);
		    
		}
	

		@RequestMapping("/yck")
		@ResponseBody
		public Object yckb(Integer pickout_id) {
		 List<PrepareOutWarehouse> getall = zservice.getall(pickout_id);
		 System.out.println(getall);
				for (PrepareOutWarehouse prepareOutWarehouse : getall) {
					for (PrepareOutWarehouse prepareOutWarehouses : getall) {
						String doneflag = prepareOutWarehouse.getDone_flag();
						if (doneflag.equals("Y")) {
							prepareOutWarehouses.setDone_flag("确认出库");
						}
						if (doneflag.equals("N")) {
							prepareOutWarehouses.setDone_flag("未确认出库");
						}
					}
				}
				return getall;
		}
		
		
		
		@RequestMapping("/updat")
		@ResponseBody
		public void updat(Integer pickout_id) {
			zservice.updat(pickout_id);
			
		}
		
		
		@RequestMapping("/dele")
		@ResponseBody
		public void dele(Integer preout_id,Integer preout_amt,PickoutProdBridge pickoutProdBridge) {
			zservice.dele(preout_id);
            zservice.upsl(pickoutProdBridge);
		}
		
		
		@RequestMapping("/upzt")
		@ResponseBody
		public void upzt(Integer pickout_id) {
			zservice.upzt(pickout_id);
		
			
		}
		
	/*	@RequestMapping("/cx")
		@ResponseBody
		public Object cx(Integer pickout_id){
		List<PickOut> queryAl = zservice.queryAl();
		for (PickOut pickOut : queryAl) {
			String done_flag = pickOut.getDone_flag();
			if (done_flag.equals("Y")) {
				pickOut.setDone_flag("拣货完成");
			}else {
				pickOut.setDone_flag("正在拣货");
			}
		}
	    
	    return queryAl;
		
		}*/
		

}
